package shop;

import java.math.BigDecimal;

/**
 * @Description：
 * 买草莓所需要支付的金额
 * 需要分打折和不打折两种情况分析
 * @Author: 杨涌仁
 * @Date: 2022/10/13
 */
public class StrawberryPay implements FruitPay {

    /**
     * 草莓没有打折需要支付的金额
     * @param weight
     * @return
     */
    @Override
    public double totalPay(int weight) {
        BigDecimal strawberryUnitPrice = new BigDecimal(String.valueOf(13));
        BigDecimal strawberryWeight = new BigDecimal(String.valueOf(weight));
        return strawberryUnitPrice.multiply(strawberryWeight).doubleValue();
    }


    /**
     * 草莓打折时需要支付的金额
     *
     * @param weight
     * @return
     */
    public double strawberryDiscountPay(int weight) {
        BigDecimal strawberryUnitPrice = new BigDecimal(String.valueOf(13));
        BigDecimal discount = new BigDecimal(String.valueOf("0.8"));
        BigDecimal strawberryWeight = new BigDecimal(String.valueOf(weight));
        return strawberryUnitPrice.multiply(discount).multiply(strawberryWeight).doubleValue();
    }

}
